package com.zzk.lanouhn.myapplication1.fragments;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.zzk.lanouhn.myapplication1.R;
import com.zzk.lanouhn.myapplication1.modles.MessageEvent;

import org.greenrobot.eventbus.EventBus;

/**
 * 侧滑菜单
 * Created by lanouhn on 16/8/25.
 */
public class LeftMenuFragment extends Fragment implements View.OnClickListener {

    private ImageView iv_back;
    private TextView tv_all, tv_start, tv_afterb, tv_company, tv_capital, tv_deep, tv_study, tv_ketv;

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
                             @Nullable Bundle savedInstanceState) {
        View view = LayoutInflater.from(getActivity()).inflate(R.layout.left_menu, null);
        initView(view);
        initEvent();
        return view;
    }

    @Override
    public void onViewCreated(final View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);

    }

    private void initView(View view) {
        iv_back = (ImageView) view.findViewById(R.id.iv_back_menu);
        tv_all = (TextView) view.findViewById(R.id.tv_all_menu_news);
        tv_start = (TextView) view.findViewById(R.id.tv_earlyproject_menu_news);
        tv_afterb = (TextView) view.findViewById(R.id.tv_afterB_menu_news);
        tv_company = (TextView) view.findViewById(R.id.tv_company_menu_news);
        tv_capital = (TextView) view.findViewById(R.id.tv_capital_menu_news);
        tv_deep = (TextView) view.findViewById(R.id.tv_deep_menu_news);
        tv_study = (TextView) view.findViewById(R.id.tv_study_menu_news);
//        tv_ketv = (TextView) view.findViewById(R.id.tv_ketv_menu_news);
    }

    private void initEvent() {
        iv_back.setOnClickListener(this);
        tv_all.setOnClickListener(this);
        tv_start.setOnClickListener(this);
        tv_afterb.setOnClickListener(this);
        tv_company.setOnClickListener(this);
        tv_capital.setOnClickListener(this);
        tv_deep.setOnClickListener(this);
        tv_study.setOnClickListener(this);
//        tv_ketv.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.iv_back_menu:
                EventBus.getDefault().post(new MessageEvent(R.id.iv_back_menu));
                break;
            case R.id.tv_all_menu_news:
                EventBus.getDefault().post(new MessageEvent(R.id.tv_all_menu_news));
                break;
            case R.id.tv_earlyproject_menu_news:
                EventBus.getDefault().post(new MessageEvent(R.id.tv_earlyproject_menu_news));
                break;
            case R.id.tv_afterB_menu_news:
                EventBus.getDefault().post(new MessageEvent(R.id.tv_afterB_menu_news));
                break;
            case R.id.tv_company_menu_news:
                EventBus.getDefault().post(new MessageEvent(R.id.tv_company_menu_news));
                break;
            case R.id.tv_capital_menu_news:
                EventBus.getDefault().post(new MessageEvent(R.id.tv_capital_menu_news));
                break;
            case R.id.tv_deep_menu_news:
                EventBus.getDefault().post(new MessageEvent(R.id.tv_deep_menu_news));
                break;
            case R.id.tv_study_menu_news:
                EventBus.getDefault().post(new MessageEvent(R.id.tv_study_menu_news));
                break;
//            case R.id.tv_ketv_menu_news:
//                EventBus.getDefault().post(new MessageEvent(R.id.tv_ketv_menu_news));
//                break;

        }
    }

}
